package com.omega_r.omegarecyclerview;

import com.omega_r.omegarecyclerview.ListAdapterExample.ListAdapterAbility;
import com.omega_r.omegarecyclerview.expandable_example.ChooseExpandableAbility;
import com.omega_r.omegarecyclerview.pagination_example.PaginationAbility;
import com.omega_r.omegarecyclerview.sections_example.SectionsAbility;
import com.omega_r.omegarecyclerview.sticky_header_example.StickyHeaderAbility;
import com.omega_r.omegarecyclerview.swipe_menu_example.SwipeMenuAbility;
import com.omega_r.omegarecyclerview.viewpager.ViewPagerAbility;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;

public class MainAbility extends Ability implements Component.ClickedListener {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_main);
        findComponentById(ResourceTable.Id_button_swipe_menu).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_sticky_header).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_pagination).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_sections).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_viewpager).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_list_adapter).setClickedListener(this);
        findComponentById(ResourceTable.Id_button_expandable_recyclerview).setClickedListener(this);
    }

    @Override
    public void onClick(Component component) {
        Intent intent = new Intent();
        Operation operation = null;
        switch (component.getId()) {
            case ResourceTable.Id_button_swipe_menu:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(SwipeMenuAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_sticky_header:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(StickyHeaderAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_pagination:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(PaginationAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_sections:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(SectionsAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_viewpager:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(ViewPagerAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_list_adapter:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(ListAdapterAbility.class.getName())
                        .build();
                break;
            case ResourceTable.Id_button_expandable_recyclerview:
                operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName(getBundleName())
                        .withAbilityName(ChooseExpandableAbility.class.getName())
                        .build();
                break;
        }
        intent.setOperation(operation);
        startAbility(intent);
    }
}
